home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / misc / doscyber / src / gunbit.c < prev    next >
Encoding:
Text File  |  1995-02-16  |  28.6 KB  |  955 lines

  1. nstrate the GetImage and PutImage commands }
  2.  
  3. const
  4.   r  = 20;
  5.   StartX = 100;
  6.   StartY = 50;
  7.  
  8. var
  9.   CurPort : ViewPortType;
  10.  
  11. procedure MoveSaucer(var X, Y : integer; Width, Height : integer);
  12. var
  13.   Step : integer;
  14. begin
  15.   Step := Random(2*r);
  16.   if Odd(Step) then
  17.     Step := -Step;
  18.   X := X + Step;
  19.   Step := Random(r);
  20.   if Odd(Step) then
  21.     Step := -Step;
  22.   Y := Y + Step;
  23.  
  24.   { Make saucer bounce off viewport walls }
  25.   with CurPort do
  26.   begin
  27.     if (x1 + X + Width - 1 > x2) then
  28.       X := x2-x1 - Width + 1
  29.     else
  30.       if (X < 0) then
  31.         X := 0;
  32.     if (y1 + Y + Height - 1 > y2) then
  33.       Y := y2-y1 - Height + 1
  34.     else
  35.       if (Y < 0) then
  36.         Y := 0;
  37.   end;
  38. end; { MoveSaucer }
  39.  
  40. var
  41.   Pausetime : word;
  42.   Saucer    : pointer;
  43.   X, Y      : integer;
  44.   ulx, uly  : word;
  45.   lrx, lry  : word;
  46.   Size      : word;
  47.   I         : word;
  48. begin
  49.   ClearDevice;
  50.   FullPort;
  51.  
  52.   { PaintScreen }
  53.   ClearDevice;
  54.   MainWindow('GetImage / PutImage Demonstration');
  55.   StatusLine('Esc aborts or press a key...');
  56.   GetViewSettings(CurPort);
  57.  
  58.   { DrawSaucer }
  59.   Ellipse(StartX, StartY, 0, 360, r, (r div 3)+2);
  60.   Ellipse(StartX, StartY-4, 190, 357, r, r div 3);
  61.   Line(StartX+7, StartY-6, StartX+10, StartY-12);
  62.   Circle(StartX+10, StartY-12, 2);
  63.   Line(StartX-7, StartY-6, StartX-10, StartY-12);
  64.   Circle(StartX-10, StartY-12, 2);
  65.   SetFillStyle(SolidFill, MaxColor);
  66.   FloodFill(StartX+1, StartY+4, GetColor);
  67.  
  68.   { ReadSaucerImage }
  69.   ulx := StartX-(r+1);
  70.   uly := StartY-14;
  71.   lrx := StartX+(r+1);
  72.   lry := StartY+(r div 3)+3;
  73.  
  74.   Size := ImageSize(ulx, uly, lrx, lry);
  75.   GetMem(Saucer, Size);
  76.   GetImage(ulx, uly, lrx, lry, Saucer^);
  77. {  PutImage(ulx, uly, Saucer^, XORput);               { erase image }
  78.  
  79.   { Plot some "stars" }
  80.   for I := 1 to 1000 do
  81.      PutPixel(Random(MaxX), Random(MaxY), RandColor);
  82.   X := MaxX div 2;
  83.   Y := MaxY div 2;
  84.   PauseTime := 70;
  85.  
  86.   { Move the saucer around }
  87.   repeat
  88. {     PutImage(X, Y, Saucer^, XORput);                 { draw image }
  89.      Delay(PauseTime);
  90. {     PutImage(X, Y, Saucer^, XORput);                 { erase image }
  91.      MoveSaucer(X, Y, lrx - ulx + 1, lry - uly + 1);  { width/height }
  92.   until KeyPressed;
  93.   FreeMem(Saucer, size);
  94.   WaitToGo;
  95. end; { PutImagePlay }
  96.  
  97. procedure PolyPlay;
  98. { Draw random polygons with random fill styles on the screen }
  99. const
  100.   MaxPts = 5;
  101. type
  102.   PolygonType = array[1..MaxPts] of PointType;
  103. var
  104.   Poly : PolygonType;
  105.   I, Color : word;
  106. begin
  107.   MainWindow('FillPoly demonstration');
  108.   StatusLine('Esc aborts or press a key...');
  109.   repeat
  110.     Color := RandColor;
  111.     SetFillStyle(Random(11)+1, Color);
  112.     SetColor(Color);
  113.     for I := 1 to MaxPts do
  114.       with Poly[I] do
  115.       begin
  116.         X := Random(MaxX);
  117.         Y := Random(MaxY);
  118.       end;
  119.     FillPoly(MaxPts, Poly);
  120.   until KeyPressed;
  121.   WaitToGo;
  122. end; { PolyPlay }
  123.  
  124. procedure FillStylePlay;
  125. { Display all of the predefined fill styles available }
  126. var
  127.   Style    : word;
  128.   Width    : word;
  129.   Height   : word;
  130.   X, Y     : word;
  131.   I, J     : word;
  132.   ViewInfo : ViewPortType;
  133.  
  134. procedure DrawBox(X, Y : word);
  135. begin
  136.   SetFillStyle(Style, MaxColor);
  137.   with ViewInfo do
  138.     Bar(X, Y, X+Width, Y+Height);
  139.   Rectangle(X, Y, X+Width, Y+Height);
  140.   OutTextXY(X+(Width div 2), Y+Height+4, Int2Str(Style));
  141.   Inc(Style);
  142. end; { DrawBox }
  143.  
  144. begin
  145.   MainWindow('Pre-defined fill styles');
  146.   GetViewSettings(ViewInfo);
  147.   with ViewInfo do
  148.   begin
  149.     Width := 2 * ((x2+1) div 13);
  150.     Height := 2 * ((y2-10) div 10);
  151.   end;
  152.   X := Width div 2;
  153.   Y := Height div 2;
  154.   Style := 0;
  155.   for J := 1 to 3 do
  156.   begin
  157.     for I := 1 to 4 do
  158.     begin
  159.       DrawBox(X, Y);
  160.       Inc(X, (Width div 2) * 3);
  161.     end;
  162.     X := Width div 2;
  163.     Inc(Y, (Height div 2) * 3);
  164.   end;
  165.   SetTextJustify(LeftText, TopText);
  166.   WaitToGo;
  167. end; { FillStylePlay }
  168.  
  169. procedure FillPatternPlay;
  170. { Display some user defined fill patterns }
  171. const
  172.   Patterns : array[0..11] of FillPatternType = (
  173.   ($AA, $55, $AA, $55, $AA, $55, $AA, $55 üÖü üÖü  !BBäx!!!BBäx!BBäx"""DDêp""DDêp>"""BBääêp""!"BDäêêp>IÉÆ|      ° @≥î>00>><Dêx  !BBäx""DDêp&<"DDêê&22TTêêê$> $< @äêp>          ⁿBBBB<  @@Ç****DDDDDDDU¬U¬U¬U¬U¬U¬U¬▌w▌w▌w▌w▌w▌w▌w°°°≥■°°≥≥■≥≥■■°°°    ≤  ≤  ≤≤         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       ;DDD;    $"Bdÿ>@@@>||>Ac]AAA1N"A""2,  `1NA"*III*<Bü üB<<BüüüB<A" \"QIE" < <BBBB  @@    ~ ?  @ÇB$$B ""A$$"AII6 üBr»$**IIII**ccregion.  The region is defined as any pixel of
  174.             OldColor which has a path of pixels of OldColor or NewColor
  175.             with sides touching back to the seed point, (XSeed, YSeed).
  176.             Therefore, only pixels of OldColor are modified and no other
  177.             information is changed.
  178.  
  179.             SEE ALSO
  180.  
  181.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  182.             FILLCONVEXPOLY, FILLPAGE, FILLPOLY, FILLSCREEN, FILLVIEW,
  183.             SETVIEW
  184.  
  185.             EXAMPL(HNxHHO$B<BBBB<$<BBBB<<BBBB<$BBBBBF:0BBBBF:$BBBF:B<""AAA""AAAAA"<B@@B<" <2\A">>xDDxDNDD <` <>BB= > <BBBB< BBBBF:2L\bBBBB&AaQIECA8$>""">0@@A>@@@ b$(. b$(*
  186.     $    $    $DDDDDDD¬U¬U¬U¬U¬U¬U¬Uw▌w▌w▌w▌w▌w▌w▌°°°⌠ⁿ°°⌠⌠ⁿ⌠⌠ⁿⁿ°°°    ≈  ≈  ≈≈         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       7HH7"B\DBBRL~BB@@@@@@?R~!!~?DDDD8BBBB|@@Ç>P>III>"AA""AAA"Uw<DDDD86II6"EIQ"\ @@ "AAAAA> >     hH02L2L$$<H(,$<>>>>>>>         VMODE=VIDEOMODEGET
  187.             IF WHICHVGA = 0 THEN STOP
  188.             DUMMY=RES640
  189.             SETVIEW 100, 100, 539, 379
  190.             FILLVIEW 10
  191.             WHILE INKEY$ = ""
  192.             WEND
  193.             VIDEOMODESET VMODE
  194.             END
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.                                                                          63
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.           FONTGETINFO
  219.  
  220.             PROTOTYPE
  221.  
  222.             SUB FONTGETINFO (Width%, Height%)
  223.  
  224.             INPUT
  225.  
  226.             no input parameters
  227.     WEND
  228.             MOUSEEXIT
  229.             VIDEOMODESET VMODE
  230.             END
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.                                                                          86
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.           MOUSECURSORDEFAULT
  279.  
  280.             PROTOTYPE
  281.  
  282.             SUB MOUSECURSORDEFAULT ()
  283.  
  284.             INPUT
  285.  
  286.             no input parameters
  287.  
  288.             OUTPUT
  289.  
  290.             no value returned
  291.  
  292.             USAGE
  293.  
  294.             MOUSECURSORDEFAULT defines the mouse cursor to be a small
  295.        ,K$╖┼╘╤░XQ)σ┤ö≡÷┴─┤àñT┘,╘¬àñX9╘⌠àñ\9╘UÜ╢≤`9╘4a╘d9╘UTa╘h9╘ta╘l9╘Uöa╘p9╘┤a╘t┘PT±x┴îÇ╖0▓ïα│ÅαU┤ôα╡ùα╢¢α╖úΓ╘pǺΓ╕¡αë ╚┴πì°sKÉφb<$⌡▌ë     φë φë I1φë  Eφë $YφÆë (mφë ,üφë 0$òφë á⌐φë ñ╜φë I¿╤φë ¼σφë ░∙φÆë 4
  296. ²ë ┤!²ë ╕$5²ë ╝I²ë └]²ë ⌐8q²ë <àⁿΦiǬ∙PÖÇ ¥Ç
  297. ░╨â@%8@ΓΦá╝╤░≡cÑÅ*$
  298. ░╕≡ż≡τ╥m¿⌡ε    ╨@#µ≈$âh$âαra╨à`¥è∩Ç%Ç +─▀ TîcOî∩â°1<@  [$¿Ç¼ MMl·0ƒ Y¼─!%6a▐è ¥ì ßá+?±  P<îaTTV ╪iÇ¡≥░ `_ñ»%Çá᪠P█º»ε`éa∙É%H«┴íA%Gár∙É
  299. iw∙Éiφ`╧≥≡╤Çmⁿ▒
  300. ]ÆAáσw7░⌡∩    $·╟Ç√É&^`  ┐ $ⁿ  $■ $╒ nk$J-ÉQ1£PéBù »0αQ/Ñ4╜£░ºP≈Ñ4Ç⌡$(ª▀$@C]Æé≈└╕_SÇçÑ4=iÉ⌠ä╣<_np@Ñ45ò▒Y3ü¼Qí░.i>╠@5+┴╙É╛╙$@ #┴@«╦
  301. $╤
  302. #@Ñú4,p&e÷ü¼_ÇQºÑ4
  303. òQ  ü@;¡_áQ@e╠≥@mp!┤a╘O░√`Pñź ÇT°8ÿ!¼Åñ$½╙"q¿ PñCÇ¿α√└╥░eT"ß<p°%Pæ(╧%pδ¥/OêW0Ǽbφ φ B@[â¼8â≥µ≤(    ¿⌡%(Ç∩áTÿp+ óÜ▓0!Σ±(1±
  304. ░┤ÖÇD└D0Å╡`   $ «îO@╧1
  305. a╝╤j-0ñ│`@╖bΦaT1═⌠╝╤Σ²¼±,1öíî9lÿ28ÇÅ`Γî¿P²$,N0┴O0a╫δ≤0σú`°î╖#0δ≡└X▄1»Σî(▒¥Ç█Ñ"qá√1CÇú╟╨º Å
  306. FT Θ²î└1ÇY0    w ²à░$@AÅ`╦Φ¼╘`▄1A  }┐Ç*5 ΩSδδî`¼îaδæ¼î5 1¿⌡Ω╜⌠ ¼¥╬ü└Qî1S
  307. ╛≤î9╨iÇ,∙PU(}Ç$üÇ àÇ`σìÇ`QαÜBO$%ÿÇ╧"$Ç«Ç]É.┬\`%WÉ$  W0 ÄâO0]αG┬ur╩
  308. ░£▒
  309. Q¢ú╔Ç≡°s?`X0╘`@ µWâ@╣aá εdq`¥9?Ç&+o0µyÄΣAÅuV(7P╬±@IdQ╕@Å┤@;Ç▓?Çò│CÇ┤╟╨╡KÇÄ30ⁿφ° ó╬ì+]Ä╦≡     Mö╝σ ²y5<!└▀óâ╝É3~mp    $<╛≤9Æ-2ⁿ≡@T,╞Σa,)Pæ└¥#¼╪Q┤S(¼@Aîa
  310. ≡╤@Ö²±⌠KëD─┴▒▀0╨Ñ$╩-0 ╨ê*╙▓edm`î=3Kß-10è=≥≤²└£mîjy ÿe²ⁿ╨i╕e▓ΣmαÖ╢C%Ç*ê*0 EátQZ`mÄLP%    °üⁿªüNQ∙  T¿<qtWΩc z░ÅÇñΩçǪçÇ«;└<┐á¼¥. á?<Σscî)áí := 0;
  311.       end;
  312.     end;
  313.   end;
  314.   WaitToGo;
  315. end; { UserLineStylePlay }
  316.  
  317.  
  318. procedure SayGoodbye;
  319. { Say goodbye and then exit the program }
  320. var
  321.   ViewInfo : ViewPortType;
  322. begin
  323.   MainWindow('');
  324.   GetViewSettings(ViewInfo);
  325.   SetTextStyle(TriplexFont, HorizDir, 4);
  326.   SetTextJustify(CenterText, CenterText);
  327.   with ViewInfo do
  328.     OutTextXY((x2-x1) div 2, (y2-y1) div 2, 'That''s all folks!');
  329.   StatusLine('Press any key to quit...');
  330.   repeat until KeyPressed;
  331. end; { SayGoodbye }
  332.  
  333.  
  334. PROCEDURE SelectMode;
  335. VAR
  336.     choice1,choice2     : CHAR;
  337.    xsize,ysize            : WORD;
  338. BEGIN
  339.     (* Let's select a mode *)
  340.     ClrScr;
  341.     WriteLn('VESADEMO:');
  342.     WriteLn('1. 256 colors');
  343.     WriteLn('2. 32768 colors');
  344.     WriteLn('3. 65536 colors');
  345.     WriteLn('4. 16777216 colors');
  346.     WriteLn('Q uit');
  347.     WriteLn;
  348.     Write('Your choice: ');
  349.     REPEAT
  350.         ReadLn(choice1);
  351.       IF choice1 <> '1' THEN BEGIN
  352.           WriteLn('Sorry !');
  353.          WriteLn('This demo wasn''t written for more as 256 colors !');
  354.          WriteLn('You would only get a limited impression of the Hi-& TrueColor modes...');
  355.          WriteLn('Switching to 256 colors.');
  356.          choice1 := '1';
  357.       END;
  358.     UNTIL choice1 IN ['1'..'4','q'];
  359.     IF choice1 = 'q' THEN Halt;
  360.  
  361.     WriteLn;
  362.     WriteLn;
  363.     WriteLn('a. 320x200');
  364.     WriteLn('b. 640x480');
  365.     WriteLn('c. 800x600');
  366.     WriteLn('d. 1024x768');
  367.     WriteLn('e. 1280x1024');
  368.     WriteLn('Q uit');
  369.     WriteLn;
  370.     Write('Your choice: ');
  371.     REPEAT
  372.         ReadLn(choice2);
  373.     UNTIL choice2 IN ['a'..'e','q'];
  374.     IF choice2 = 'q' THEN Halt;
  375.  
  376.     CASE choice2 OF
  377.         'a' : BEGIN
  378.             xsize := 320;
  379.             ysize := 200;
  380.         END;
  381.         'b' : BEGIN
  382.             xsize := 640;
  383.             ysize := 480;
  384.         END;
  385.         'c' : BEGIN
  386.             xsize := 800;
  387.             ysize := 600;
  388.         END;
  389.         'd' : BEGIN
  390.             xsize := 1024;
  391.             ysize := 768;
  392.         END;
  393.         'e' : BEGIN
  394.             xsize := 1280;
  395.             ysize := 1024;
  396.         END;
  397.     END;
  398.     CASE choice1 OF
  399.         '1' : mode := FindVesaMode(xsize,ysize,8);
  400.         '2' : mode := FindVesaMode(xsize,ysize,15);
  401.         '3' : mode := FindVesaMode(xsize,ysize,16);
  402.         '4' : mode := FindVesaMode(xsize,ysize,24);
  403.     END;
  404.     IF mode = 0 THEN BEGIN
  405.         WriteLn('No such mode could be found !');
  406.         WriteLn('Switching to to 320x200.');
  407.         ReadKey;
  408.         mode := V320x200x256;
  409.     END;
  410. END;
  411.  
  412. begin { program body }
  413.   SelectMode;
  414.   Initialize;
  415.   ReportStatus;
  416.  
  417. {  AspectRatioPlay; }
  418.   FillEllipsePlay;
  419.   SectorPlay;
  420.   WriteModePlay;
  421.  
  422.   ColorPlay;
  423.   { PalettePlay only intended to work on these drivers: }
  424.   if (GraphDriver = EGA) or
  425.       (GraphDriver = EGA64) or
  426.       (GraphDriver = VGA) then
  427.      PalettePlay;
  428.   PutPixelPlay;
  429. {  PutImagePlay; }
  430.   RandBarPlay;
  431.   BarPlay;
  432.   Bar3DPlay;
  433.   ArcPlay;
  434.   CirclePlay;
  435.   PiePlay;
  436.   LineToPlay;
  437.   LineRelPlay;
  438. {  LineStylePlay; }
  439. {  UserLineStylePlay; }
  440.   TextDump;
  441.   TextPlay;
  442.   CrtModePlay;
  443.   FillStylePlay;
  444.   FillPatternPlay;
  445.   PolyPlay;
  446.   SayGoodbye;
  447. {  CloseGraph; }
  448.   CloseVesa;
  449. end.
  450. ***************************************************
  451.     '* SHOW D2ROTATE (ABOUT THE ORIGIN)
  452.     '****************************************************************∞╥≤c≤*φè#^│v/╒:j═φ0t+l▓ô"¬"g└≡?%ªêΣ│H╫½╫╜├¿U'╒⌐⌡ ßV?╩
  453. ¬ujOΦçEZ1∞▐! ▄B╛Σ8║æ]1GlNÜ┐q▌▓;ô$ΦzE<cª*bEô#ä╧ñÅ"∩─LrdaÖ ╠º╫a^¥£å╬1~)@ëÖMδ╫0═6DäFê¬Çv┼ß╨kæpτ╪É)}ª 1w3╤╧ü⌡¥╓h▓╣≈ïÅaÑ[TⁿHqªÉ╝DKÄ─Y-∞tT╤Θ╨º╟╪.*ÇI9lΦ≈{πτcσ$τπßoFr╪╨∩┼╞╟;O2■e²LÜ4^N|╪½ÅO?╔°FOz`╟╟╟'<>>π$πΘù6·
  454. Xgî╖│°oîδπGƒd╝▀░?■╪╔_9L ⌡ôⁿq'æO▀ƒn4╔▀╚▄┼3pτ.òO°·}÷╕ⁿ±'æO?ít│!√8ßÑ≤/┐╣p┼≥┘E╦Vox╕cΦé5╟╚º╙$?√$≥ΘZεsî≡åìΓpKù¢ïß X╥ 9╞≈\µk┤O¥_ 5Üö\≤éÄ┌╤A[╤ÿáï┼éNⁿÅu16    g,%hc╙╨cD╨Vï┘R¢öKñR;8εáΣ╢╪ós╤π╡á└èxgzPÄMú╫yαºÉ+σJ¢i+▓â3╥    ═Ñ╙î^ºG▓█πérφçs %#(╗⌠?┼%u8≡6+QÉ))ò)Afw≈╣╪)B&4░åLXV:δät@Å.;5Φf╢Ät┐ΣJ╫─U8úÇ╟éö£╕p╔┴⌠vg╨╬╥é÷╪╣┬ΓI.ç≡^v╤ZΦÇ& ╒┌6ñô6XßNè╡╬E₧Ñ
  455. kIº╠▄A+╣╥éb²tæ-Y¡½αÑa═uuîÇ╢αêvhuª╡SÅ┤vèùú¥F;p<d⌐/F─d█éT%▓KΦû=q■öI┐ ┐╠6S$▒÷╚ENΩ¥Fû9╔┌R'╝ ╧φ└?g┬j▓0═/b╖₧─mûé╢┌»ÿÄë/·<éò■░╤╟╢├Xσ:╥P3Θ"╬Læsφ░┌öSö!╗¿*mN£WΣÇ£┤~#╗ææ≥RΩóh:à▌.æ≈╕▌v£äàd▒à╒├=░╖π║$howeg*╬    6ù▄ƒô╕φ░Ö╢qΘD>(w@úKεHÆ╛öúΣU
  456. éÜR╔╤W▄èê 2M%ó.▓SNÖA1ùJE╢║l]▓¿>\%└Å4ßO▄£â⌐& ê/)8vSP▀▓ôⁿææ√ü√ÑÄa⌠â╚4S╓╟P- ?Σá╕▓Næ*q╡UΘ▓≈^ñ·I.rúR&$Y^╚%è≡B┌≈Ceat
  457.     Color := RandColor;
  458.     SetColor(Color);
  459.     SetFillStyle(Random(CloseDotFill)+1, Color);
  460.     Bar3D(Random(MaxWidth), Random(MaxHeight),
  461.           Random(MaxWidth), Random(MaxHeight), 0, TopOff);
  462.   until KeyPressed;
  463.   WaitToGo;
  464. end; { RandBarPlay }
  465.  
  466. procedure ArcPlay;
  467. { Draw random arcs on the screen }
  468. var
  469.   MaxRadius : word;
  470.   EndAngle : word;
  471.   ArcInfo : ArcCoordsType;
  472. begin
  473.   MainWindow('Arc / GetArcCoords demonstration');
  474.   StatusLine('Esc aborts or press a key');
  475.   MaxRadius := MaxY div 10;
  476.   repeat
  477.     SetColor(RandColor);
  478.     EndAngle := Random(360);
  479.     SetLineStyle(SolidLn, 0, NormWidth);
  480.     Arc(Random(MaxX), Random(MaxY), Random(EndAngle), EndAngle, Random(MaxRadius));
  481.     GetArcCoords(ArcInfo);
  482.     with ArcInfo do
  483.     begin
  484.       Line(X, Y, XStart, YStart);
  485.       Line(X, Y, Xend, Yend);
  486.     end;
  487.   until KeyPressed;
  488.   WaitToGo;
  489. end; { ArcPlay }
  490.  
  491. procedure PutPixelPlay;
  492. { Demonstrate the PutPixel and GetPixel commands }
  493. const
  494.   Seed   = 1962; { A seed for the random number generator }
  495.   NumPts = 2000; { The number of pixels plotted }
  496.   Esc    = #27;
  497. var
  498.   I : word;
  499.   X, Y, Color : word;
  500.   XMax, YMax  : integer;
  501.   ViewInfo    : ViewPortType;
  502. begin
  503.   MainWindow('PutPixel / GetPixel demonstration');
  504.   StatusLine('Esc aborts or press a key...');
  505.  
  506.   GetViewSettings(ViewInfo);
  507.   with ViewInfo do
  508.   begin
  509.     XMax := (x2-x1-1);
  510.     YMax := (y2-y1-1);
  511.   end;
  512.  
  513.   while not KeyPressed do
  514.   begin
  515.     { Plot random pixels }
  516.     RandSeed := Seed;
  517.     I := 0;
  518.     while (not KeyPressed) and (I < NumPts) do
  519.     begin
  520.       Inc(I);
  521.         PutPixel(Random(XMax)+1, Random(YMax)+1, RandColor);
  522.     end;
  523.  
  524.     { Erase pixels }
  525.     RandSeed := Seed;
  526.     I := 0;
  527.     while (not KeyPressed) and (I < NumPts) do
  528.     begin
  529.       Inc(I);
  530.       X := Random(XMax)+1;
  531.       Y := Random(YMax)+1;
  532.       Color := GetPixel(X, Y);
  533.         if Color = RandColor then
  534.           PutPixel(X, Y, 0);
  535.      end;
  536.   end;
  537.   WaitToGo;
  538. end; { PutPixelPlay }
  539.  
  540. procedure PutImagePlay;
  541. { Demonstrate the GetImage and PutImage commands }
  542.  
  543. const
  544.   r  = 20;
  545.   StartX = 100;
  546.   StartY = 50;
  547.  
  548. var
  549.   CurPort : ViewPortType;
  550.  
  551. procedure MoveSaucer(var X, Y : integer; Width, Height : integer);
  552. var
  553.   Step : integer;
  554. begin
  555.   Step := Random(2*r);
  556.   if Odd(Step) then
  557.     Step := -Step;
  558.   X := X + Step;
  559.   Step := Random(r);
  560.   if Odd(Step) then
  561.     Step := -Step;
  562.   Y := Y + Step;
  563.  
  564.   { Make saucer bounce off viewport walls }
  565.   with CurPort do
  566.   begin
  567.     if (x1 + X + Width - 1 > x2) then
  568.       X := x2-x1 - Width + 1
  569.     else
  570.       if (X < 0) then
  571.         X := 0;
  572.     if (y1 + Y + Height - 1 > y2) then
  573.       Y := y2-y1 - Height + 1
  574.     else
  575.       if (Y < 0) then
  576.         Y := 0;
  577.   end;
  578. end; { MoveSaucer }
  579.  
  580. var
  581.   Pausetime : word;
  582.   Saucer    : pointer;
  583.   X, Y      : integer;
  584.   ulx, uly  : word;
  585.   lrx, lry  : word;
  586.   Size      : word;
  587.   I         : word;
  588. begin
  589.   ClearDevice;
  590.   FullPort;
  591.  
  592.   { PaintScreen }
  593.   ClearDevice;
  594.   MainWindow('GetImage / PutImage Demonstration');
  595.   StatusLine('Esc aborts or press a key...');
  596.   GetViewSettings(CurPort);
  597.  
  598.   { DrawSaucer }
  599.   Ellipse(StartX, StartY, 0, 360, r, (r div 3)+2);
  600.   Ellipse(StartX, StartY-4, 190, 357, r, r div 3);
  601.   Line(StartX+7, StartY-6, StartX+10, StartY-12);
  602.   Circle(StartX+10, StartY-12, 2);
  603.   Line(StartX-7, StartY-6, StartX-10, StartY-12);
  604.   Circle(StartX-10, StartY-12, 2);
  605.   SetFillStyle(SolidFill, MaxColor);
  606.   FloodFill(StartX+1, StartY+4, GetColor);
  607.  
  608.   { ReadSaucerImage }
  609.   ulx := StartX-(r+1);
  610.   uly := StartY-14;
  611.   lrx := StartX+(r+1);
  612.   lry := StartY+(r div 3)+3;
  613.  
  614.   Size := ImageSize(ulx, uly, lrx, lry);
  615.   GetMem(Saucer, Size);
  616.   GetImage(ulx, uly, lrx, lry, Saucer^);
  617. {  PutImage(ulx, uly, Saucer^, XORput);               { erase image }
  618.  
  619.   { Plot some "stars" }
  620.   for I := 1 to 1000 do
  621.      PutPixel(Random(MaxX), Random(MaxY), RandColor);
  622.   X := MaxX div 2;
  623.   Y := MaxY div 2;
  624.   PauseTime := 70;
  625.  
  626.   { Move the saucer around }
  627.   repeat
  628. {     PutImage(X, Y, Saucer^, XORput);                 { draw image }
  629.      Delay(PauseTime);
  630. {     PutImage(X, Y, Saucer^, XORput);                 { erase image }
  631.      MoveSaucer(X, Y, lrx - ulx + 1, lry - uly + 1);  { width/height }
  632.   until KeyPressed;
  633.   FreeMem(Saucer, size);
  634.   WaitToGo;
  635. end; { PutImagePlay }
  636.  
  637. procedure PolyPlay;
  638. { Draw random polygons with random fill styles on the screen }
  639. const
  640.   MaxPts = 5;
  641. type
  642.   PolygonType = array[1..MaxPts] of PointType;
  643. var
  644.   Poly : PolygonType;
  645.   I, Color : word;
  646. begin
  647.   MainWindow('FillPoly demonstration');
  648.   StatusLine('Esc aborts or press a key...');
  649.   repeat
  650.     Color := RandColor;
  651.     SetFillStyle(Random(11)+1, Color);
  652.     SetColor(Color);
  653.     for I := 1 to MaxPts do
  654.       with Poly[I] do
  655.       begin
  656.         X := Random(MaxX);
  657.         Y := Random(MaxY);
  658.       end;
  659.     FillPoly(MaxPts, Poly);
  660.   until KeyPressed;
  661.   WaitToGo;
  662. end; { PolyPlay }
  663.  
  664. procedure FillStylePlay;
  665. { Display all of the predefined fill styles available }
  666. var
  667.   Style    : word;
  668.   Width    : word;
  669.   Height   : word;
  670.   X, Y     : word;
  671.   I, J     : word;
  672.   ViewInfo : ViewPortType;
  673.  
  674. procedure DrawBox(X, Y : word);
  675. begin
  676.   SetFillStyle(Style, MaxColor);
  677.   with ViewInfo do
  678.     Bar(X, Y, X+Width, Y+Height);
  679.   Rectangle(X, Y, X+Width, Y+Height);
  680.   OutTextXY(X+(Width div 2), Y+Height+4, Int2Str(Style));
  681.   Inc(Style);
  682. end; { DrawBox }
  683.  
  684. begin
  685.   MainWindow('Pre-defined fill styles');
  686.   GetViewSettings(ViewInfo);
  687.   with ViewInfo do
  688.   begin
  689.     Width := 2 * ((x2+1) div 13);
  690.     Height := 2 * ((y2-10) div 10);
  691.   end;
  692.   X := Width div 2;
  693.   Y := Height div 2;
  694.   Style := 0;
  695.   for J := 1 to 3 do
  696.   begin
  697.     for I := 1 to 4 do
  698.     begin
  699.       DrawBox(X, Y);
  700.       Inc(X, (Width div 2) * 3);
  701.     end;
  702.     X := Width div 2;
  703.     Inc(Y, (Height div 2) * 3);
  704.   end;
  705.   SetTextJustify(LeftText, TopText);
  706.   WaitToGo;
  707. end; { FillStylePlay }
  708.  
  709. procedure FillPatternPlay;
  710. { Display some user defined fill patterns }
  711. const
  712.   Patterns : array[0..11] of FillPatternType = (
  713.   ($AA, $55, $AA, $55, $AA, $55, $AA, $55 üÖü üÖü  !BBäx!!!BBäx!BBäx"""DDêp""DDêp>"""BBääêp""!"BDäêêp>IÉÆ|      ° @≥î>00>><Dêx  !BBäx""DDêp&<"DDêê&22TTêêê$> $< @äêp>          ⁿBBBB<  @@Ç****DDDDDDDU¬U¬U¬U¬U¬U¬U¬▌w▌w▌w▌w▌w▌w▌w°°°≥■°°≥≥■≥≥■■°°°    ≤  ≤  ≤≤         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       ;DDD;    $"Bdÿ>@@@>||>Ac]AAA1N"A""2,  `1NA"*III*<Bü üB<<BüüüB<A" \"QIE" < <BBBB  @@    ~ ?  @ÇB$$B ""A$$"AII6 üBr»$**IIII**ccregion.  The region is defined as any pixel of
  714.             OldColor which has a path of pixels of OldColor or NewColor
  715.             with sides touching back to the seed point, (XSeed, YSeed).
  716.             Therefore, only pixels of OldColor are modified and no other
  717.             information is changed.
  718.  
  719.             SEE ALSO
  720.  
  721.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  722.             FILLCONVEXPOLY, FILLPAGE, FILLPOLY, FILLSCREEN, FILLVIEW,
  723.             SETVIEW
  724.  
  725.             EXAMPL(HNxHHO$B<BBBB<$<BBBB<<BBBB<$BBBBBF:0BBBBF:$BBBF:B<""AAA""AAAAA"<B@@B<" <2\A">>xDDxDNDD <` <>BB= > <BBBB< BBBBF:2L\bBBBB&AaQIECA8$>""">0@@A>@@@ b$(. b$(*
  726.     $    $    $DDDDDDD¬U¬U¬U¬U¬U¬U¬Uw▌w▌w▌w▌w▌w▌w▌°°°⌠ⁿ°°⌠⌠ⁿ⌠⌠ⁿⁿ°°°    ≈  ≈  ≈≈         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       7HH7"B\DBBRL~BB@@@@@@?R~!!~?DDDD8BBBB|@@Ç>P>III>"AA""AAA"Uw<DDDD86II6"EIQ"\ @@ "AAAAA> >     hH02L2L$$<H(,$<>>>>>>>         VMODE=VIDEOMODEGET
  727.             IF WHICHVGA = 0 THEN STOP
  728.             DUMMY=RES640
  729.             SETVIEW 100, 100, 539, 379
  730.             FILLVIEW 10
  731.             WHILE INKEY$ = ""
  732.             WEND
  733.             VIDEOMODESET VMODE
  734.             END
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.                                                                          63
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.           FONTGETINFO
  759.  
  760.             PROTOTYPE
  761.  
  762.             SUB FONTGETINFO (Width%, Height%)
  763.  
  764.             INPUT
  765.  
  766.             no input parameters
  767.     WEND
  768.             MOUSEEXIT
  769.             VIDEOMODESET VMODE
  770.             END
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.                                                                          86
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.           MOUSECURSORDEFAULT
  819.  
  820.             PROTOTYPE
  821.  
  822.             SUB MOUSECURSORDEFAULT ()
  823.  
  824.             INPUT
  825.  
  826.             no input parameters
  827.  
  828.             OUTPUT
  829.  
  830.             no value returned
  831.  
  832.             USAGE
  833.  
  834.             MOUSECURSORDEFAULT defines the mouse cursor to be a small
  835.        ,K$╖┼╘╤░XQ)σ┤ö≡÷┴─┤àñT┘,╘¬àñX9╘⌠àñ\9╘UÜ╢≤`9╘4a╘d9╘UTa╘h9╘ta╘l9╘Uöa╘p9╘┤a╘t┘PT±x┴îÇ╖0▓ïα│ÅαU┤ôα╡ùα╢¢α╖úΓ╘pǺΓ╕¡αë ╚┴πì°sKÉφb<$⌡▌ë     φë φë I1φë  Eφë $YφÆë (mφë ,üφë 0$òφë á⌐φë ñ╜φë I¿╤φë ¼σφë ░∙φÆë 4
  836. ²ë ┤!²ë ╕$5²ë ╝I²ë └]²ë ⌐8q²ë <àⁿΦiǬ∙PÖÇ ¥Ç
  837. ░╨â@%8@ΓΦá╝╤░≡cÑÅ*$
  838. ░╕≡ż≡τ╥m¿⌡ε    ╨@#µ≈$âh$âαra╨à`¥è∩Ç%Ç +─▀ TîcOî∩â°1<@  [$¿Ç¼ MMl·0ƒ Y¼─!%6a▐è ¥ì ßá+?±  P<îaTTV ╪iÇ¡≥░ `_ñ»%Çá᪠P█º»ε`éa∙É%H«┴íA%Gár∙É
  839. iw∙Éiφ`╧≥≡╤Çmⁿ▒
  840. ]ÆAáσw7░⌡∩    $·╟Ç√É&^`  ┐ $ⁿ  $■ $╒ nk$J-ÉQ1£PéBù »0αQ/Ñ4╜£░ºP≈Ñ4Ç⌡$(ª▀$@C]Æé≈└╕_SÇçÑ4=iÉ⌠ä╣<_np@Ñ45ò▒Y3ü¼Qí░.i>╠@5+┴╙É╛╙$@ #┴@«╦
  841. $╤
  842. #@Ñú4,p&e÷ü¼_ÇQºÑ4
  843. òQ  ü@;¡_áQ@e╠≥@mp!┤a╘O░√`Pñź ÇT°8ÿ!¼Åñ$½╙"q¿ PñCÇ¿α√└╥░eT"ß<p°%Pæ(╧%pδ¥/OêW0Ǽbφ φ B@[â¼8â≥µ≤(    ¿⌡%(Ç∩áTÿp+ óÜ▓0!Σ±(1±
  844. ░┤ÖÇD└D0Å╡`   $ «îO@╧1
  845. a╝╤j-0ñ│`@╖bΦaT1═⌠╝╤Σ²¼±,1öíî9lÿ28ÇÅ`Γî¿P²$,N0┴O0a╫δ≤0σú`°î╖#0δ≡└X▄1»Σî(▒¥Ç█Ñ"qá√1CÇú╟╨º Å
  846. FT Θ²î└1ÇY0    w ²à░$@AÅ`╦Φ¼╘`▄1A  }┐Ç*5 ΩSδδî`¼îaδæ¼î5 1¿⌡Ω╜⌠ ¼¥╬ü└Qî1S
  847. ╛≤î9╨iÇ,∙PU(}Ç$üÇ àÇ`σìÇ`QαÜBO$%ÿÇ╧"$Ç«Ç]É.┬\`%WÉ$  W0 ÄâO0]αG┬ur╩
  848. ░£▒
  849. Q¢ú╔Ç≡°s?`X0╘`@ µWâ@╣aá εdq`¥9?Ç&+o0µyÄΣAÅuV(7P╬±@IdQ╕@Å┤@;Ç▓?Çò│CÇ┤╟╨╡KÇÄ30ⁿφ° ó╬ì+]Ä╦≡     Mö╝σ ²y5<!└▀óâ╝É3~mp    $<╛≤9Æ-2ⁿ≡@T,╞Σa,)Pæ└¥#¼╪Q┤S(¼@Aîa
  850. ≡╤@Ö²±⌠KëD─┴▒▀0╨Ñ$╩-0 ╨ê*╙▓edm`î=3Kß-10è=≥≤²└£mîjy ÿe²ⁿ╨i╕e▓ΣmαÖ╢C%Ç*ê*0 EátQZ`mÄLP%    °üⁿªüNQ∙  T¿<qtWΩc z░ÅÇñΩçǪçÇ«;└<┐á¼¥. á?<Σscî)áí := 0;
  851.       end;
  852.     end;
  853.   end;
  854.   WaitToGo;
  855. end; { UserLineStylePlay }
  856.  
  857.  
  858. procedure SayGoodbye;
  859. { Say goodbye and then exit the program }
  860. var
  861.   ViewInfo : ViewPortType;
  862. begin
  863.   MainWindow('');
  864.   GetViewSettings(ViewInfo);
  865.   SetTextStyle(TriplexFont, HorizDir, 4);
  866.   SetTextJustify(CenterText, CenterText);
  867.   with ViewInfo do
  868.     OutTextXY((x2-x1) div 2, (y2-y1) div 2, 'That''s all folks!');
  869.   StatusLine('Press any key to quit...');
  870.   repeat until KeyPressed;
  871. end; { SayGoodbye }
  872.  
  873.  
  874. PROCEDURE SelectMode;
  875. VAR
  876.     choice1,choice2     : CHAR;
  877.    xsize,ysize            : WORD;
  878. BEGIN
  879.     (* Let's select a mode *)
  880.     ClrScr;
  881.     WriteLn('VESADEMO:');
  882.     WriteLn('1. 256 colors');
  883.     WriteLn('2. 32768 colors');
  884.     WriteLn('3. 65536 colors');
  885.     WriteLn('4. 16777216 colors');
  886.     WriteLn('Q uit');
  887.     WriteLn;
  888.     Write('Your choice: ');
  889.     REPEAT
  890.         ReadLn(choice1);
  891.       IF choice1 <> '1' THEN BEGIN
  892.           WriteLn('Sorry !');
  893.          WriteLn('This demo wasn''t written for more as 256 colors !');
  894.          WriteLn('You would only get a limited impression of the Hi-& TrueColor modes...');
  895.          WriteLn('Switching to 256 colors.');
  896.          choice1 := '1';
  897.       END;
  898.     UNTIL choice1 IN ['1'..'4','q'];
  899.     IF choice1 = 'q' THEN Halt;
  900.  
  901.     WriteLn;
  902.     WriteLn;
  903.     WriteLn('a. 320x200');
  904.     WriteLn('b. 640x480');
  905.     WriteLn('c. 800x600');
  906.     WriteLn('d. 1024x768');
  907.     WriteLn('e. 1280x1024');
  908.     WriteLn('Q uit');
  909.     WriteLn;
  910.     Write('Your choice: ');
  911.     REPEAT
  912.         ReadLn(choice2);
  913.     UNTIL choice2 IN ['a'..'e','q'];
  914.     IF choice2 = 'q' THEN Halt;
  915.  
  916.     CASE choice2 OF
  917.         'a' : BEGIN
  918.             xsize := 320;
  919.             ysize := 200;
  920.         END;
  921.         'b' : BEGIN
  922.             xsize := 640;
  923.             ysize := 480;
  924.         END;
  925.         'c' : BEGIN
  926.             xsize := 800;
  927.             ysize := 600;
  928.         END;
  929.         'd' : BEGIN
  930.             xsize := 1024;
  931.             ysize := 768;
  932.         END;
  933.         'e' : BEGIN
  934.             xsize := 1280;
  935.             ysize := 1024;
  936.         END;
  937.     END;
  938.     CASE choice1 OF
  939.         '1' : mode := FindVesaMode(xsize,ysize,8);
  940.         '2' : mode := FindVesaMode(xsize,ysize,15);
  941.         '3' : mode := FindVesaMode(xsize,ysize,16);
  942.         '4' : mode := FindVesaMode(xsize,ysize,24);
  943.     END;
  944.     IF mode = 0 THEN BEGIN
  945.         WriteLn('No such mode could be found !');
  946.         WriteLn('Switching to to 320x200.');
  947.         ReadKey;
  948.         mode := V320x200x256;
  949.     END;
  950. END;
  951.  
  952. begin { program body }
  953.   SelectMode;
  954.   Initialize;
  955.   ReportStatus;
  956.  
  957. {  AspectRatioPlay; }
  958.   FillEllipsePlay;
  959.   SectorPlay;
  960.   WriteModePlay;
  961.  
  962.   ColorPlay;
  963.   { PalettePlay only intended to work on these drivers: }
  964.   if (GraphDriver = EGA) or
  965.       (GraphDriver = EGA64) or
  966.       (GraphDriver = VGA) then
  967.      PalettePlay;
  968.   PutPixelPlay;
  969. {  PutImagePlay; }
  970.   RandBarPlay;
  971.   BarPlay;
  972.   Bar3DPlay;
  973.   ArcPlay;
  974.   CirclePlay;
  975.   PiePlay;
  976.   LineToPlay;
  977.   Li